<p id="notice"><%= notice %></p>

<p>
  <!-- <b>Title:</b> -->
  <h1><%= @collection.title %></h1>
</p>

<p>
  <b>Books number:</b>
  <%= @collection.books_nb %>
</p>

<p>
  <b>Type:</b>
  <%= @collection.type %>
</p>

<p>
  <b>Description:</b>
  <%= @collection.description %>
</p>
<br />


<div id="books">
<p><h2>Books Listing</h2></p>
<table>
  <tr>
    <th>Title</th>
    <th>Price</th>
    <th>Isbn</th>
    <th>Description</th>
    <th></th>
    <th></th>
    <th></th>
  </tr>

<div id="rates">
<p><b>Global rate: <%= @collection_ratings.map(&:rate).sum/@collection_ratings.map(&:rate).size if @collection_ratings.map(&:rate).size > 0 %></b></p>

<% @collection_ratings.each do |collection_rating|  %>
<div id="rate">
	<p><b>Rate :</b> <%= collection_rating.rate %>/5</p>
	<p><b>Comments :</b><%= collection_rating.comment %></p>
	<br />
</div>
<% end %>
</div>
<%= link_to 'Rate me!', new_collection_collection_rating_path(@collection) %>&emsp;
<%= link_to 'Edit', edit_collection_path(@collection) %>

<hr />
<% @books.each do |book| %>
  <tr>
    <td><%=@collection %> <%= book.title %></td>
    <td><%= book.price %></td>
    <td><%= book.isbn %></td>
    <td><%= book.description %></td>
    <td><%= link_to 'Show', book %></td>
    <td><%= link_to 'Edit', edit_book_path(book) %></td>
    <td><%= link_to 'Destroy', book, :method => :delete, :data => { :confirm => 'Are you sure?' } %></td>
  </tr>
<% end %>
</table>

<br />

</div>

<%= link_to "Add a book", new_book_path %>
<%= link_to 'Back', collections_path %>

